package c.x.jy.admin.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import c.x.jy.dao.entity.DashangEntity;
import c.x.jy.service.service.DashangService;
import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.R;



/**
 * 
 *
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-07-14 13:07:08
 */
@RestController
@RequestMapping("sys/dashang")
public class DashangController extends AbstractController {
    @Autowired
    private DashangService dashangService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:dashang:list")
    public R list(@RequestParam Map<String, Object> params){
      
        PageUtils page = dashangService.queryPage(params);

        return R.put(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:dashang:info")
    public R info(@PathVariable("id") Long id){
		DashangEntity dashang = dashangService.getById(id);

        return R.put(dashang);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:dashang:save")
    public R save(@RequestBody DashangEntity dashang){
		dashangService.save(dashang);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:dashang:update")
    public R update(@RequestBody DashangEntity dashang){
		dashangService.updateById(dashang);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    @RequiresPermissions("sys:dashang:delete")
    public R delete(@PathVariable("id") Long id){
		dashangService.removeByIds(Arrays.asList(id));

        return R.ok();
    }

}

